<?php
include("../common.inc.php");
InitGP(array("page","action","iid","delids")); //初始化变量全局返回
include("function_common.php");
//初始化对象
include(INC_PATH."/invoice.class.php");
$ic=new InvoiceClass();

if(empty($action)){
	InitGP(array("order_sn","tid","delivery_sn")); //初始化变量全局返回
	if(!empty($order_sn))$wherestr[]="order_sn like '%{$order_sn}%'";
	if(!empty($tid))$wherestr[]="state in ({$tid})";
	if(!empty($delivery_sn))$wherestr[]="delivery_sn like '%{$delivery_sn}%'";
	if(!empty($wherestr)) $wheresql = implode(' AND ', $wherestr);	//条件汇总
	
	//获取当前页码
	$total=$ic->getcount($wheresql); 							  //总信息数
	$pagesize=15;												  //一页显示信息数
	$page = isset($page) ? max(1, intval($page)) : 1;             //处理页码变量
	$icffset=($page-1)*$pagesize;   								  //偏移量
	$dataarray=$ic->getdata("$icffset,$pagesize",$wheresql); //获取团购数据
	
	//包含后台模板文件
	include("tpl/invoice_list.htm");
}elseif ($action=="update") {
	//更新状态禁用或者启用
	InitGP(array("iid","state")); //初始化变量全局返回
	if(!isset($state))$state=$ic->state($iid)?0:1;
	$ic->state($iid,$state);
	showmsg("设置状态成功!","invoice_list.php");//成功

}
?>

